<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>留言列表</title> 
    <link rel="shortcut icon" href="/favicon.ico"> 
    <link href="/public/admin/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="/public/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/public/admin/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="/public/admin/css/animate.css" rel="stylesheet">
    <link href="/public/admin/css/style.css?v=4.0.0" rel="stylesheet">
    <link href="/public/admin/js/plugins/layer/skin/layer.css" rel="stylesheet">
    <base target="_blank">
<!-- 全局js -->
<script src="/public/admin/js/jquery.min.js?v=2.1.4"></script>
<script src="/public/admin/js/bootstrap.min.js?v=3.3.5"></script>
<script src="/public/admin/js/plugins/layer/layer.min.js"></script> 
<!-- 自定义js -->
<script src="/public/admin/js/content.js?v=1.0.0"></script>
<script src="/public/admin/js/contabs.js"></script>
<script src="/public/admin/js/common.js"></script>
<script src="/public/admin/js/article.js"></script> 

<!-- Bootstrap table -->
<script src="/public/admin/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="/public/admin/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="/public/admin/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>    
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>试题管理</h5>
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="box">
                                <div class="box-header">
                                    <div class="panel-body">
                                        <form id="formSearch" action="{:url('question/questionList')}" method="get" class="form-horizontal form-inline" target="_self">
                                            <b>科目：</b>
                                            <select class="form-control kind_id" name="subjectid">
                                                <option value="">所有科目</option>
                                                {foreach name="subjectList" item="v"}
                                                <option value="{$v.subjectid}" {eq name="v.subjectid" value="$inputData['subjectid']"}selected="selected"{/eq}>{$v.subject_name}</option>
                                                {/foreach}
                                            </select>
                                            <b>周次：</b>
                                            <select class="form-control kind_id" name="weekid">
                                                <option value="">所有</option>
                                                {foreach name="weekList" item="v"}
                                                <option value="{$v.weekid}" {eq name="v.weekid" value="$inputData['weekid']"}selected="selected"{/eq}>{$v.week_name}</option>
                                                {/foreach}
                                            </select>
                                            <b>题型：</b>
                                            <select class="form-control kind_id" name="qtypeid">
                                                <option value="">所有题型</option>
                                                {foreach name="qtypeList" item="v"}
                                                <option value="{$v.qtypeid}" {eq name="v.qtypeid" value="$inputData['qtypeid']"}selected="selected"{/eq}>{$v.qtype_name}</option>
                                                {/foreach}
                                            </select>
                                            <label class="control-label">关键字：</label>
                                            <input type="text" placeholder="标题关键字" name="keyword" id="keyword" value="{$inputData['keyword']}" class="form-control">
                                            <button type="submit" style="margin-left:30px" id="btn_query" class="btn btn-primary">查询</button>
                                            <a onclick="openYemian('/index.php/Admin/Question/questionAdd','添加试题')" href="javascript:;" class="btn btn-primary"><i class="fa fa-plus"></i>添加试题</a>

                                            <input type="file" id="excelfile" name="excelfile" class="form-control" style="margin-left:10px;width:200px">
                                            <button type="button"  onclick="importExcel()" style="margin-left:30px" id="" class="btn btn-primary">导入excel</button>
                                        </form>
                                        <script>
                                            var requestcode=1;
                                            function importExcel(){
                                                if(requestcode != 1){
                                                    layer.msg('提交请求中，请稍候');
                                                    return false;
                                                }
                                                var formData = new FormData($('#formSearch')[0]);
                                                formData.append('file',$('#excelfile')[0].files[0]);
                                                $.ajax({
                                                    type:'post',
                                                    url:"{:url('question/importExcel')}",
                                                    cache: false,
                                                    processData: false,
                                                    contentType: false,
                                                    async: false,
                                                    data:formData,
                                                    dataType:'json',
                                                    success:function(res){
                                                        if(res.status==1){
                                                            layer.msg(res.msg,{time:1000},function(){
                                                                window.location = window.location;
                                                            })
                                                        }else{
                                                            layer.msg(res.msg);
                                                        }
                                                        setTimeout(function(){
                                                            requestcode = 1;
                                                        },500);
                                                    }

                                                });
                                                requestcode = 0;
                                                return false;
                                            }
                                        </script>
                                    </div>                  
                                </div><!-- /.box-header -->
                                <div class="box-body">
                                    <div class="row">
                                        <div class="col-sm-12">
                                            <div id="ajaxList">
                                                
                                                <form method="post" enctype="multipart/form-data" id="form-order">
                                                <table class="table table-bordered">
                                                    <thead>
                                                    <tr>
                                                        <th style="width: 1px;display:none"><input type="checkbox" onclick="$('input[name*=\'ids\']').prop('checked', this.checked);"></th>
                                                        <th>ID</th>
                                                        <th>科目</th>
                                                        <th>周次</th>
                                                        <th>试题类型</th>
                                                        <th>试题题目</th>
                                                        <th>录入人/录入时间</th>
                                                        <th>操作</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody id="ajaxList">
                                                    {if empty($questionList)}
                                                    <tr role="row">
                                                        <td colspan="9" align="center">暂无数据</td>
                                                    </tr>
                                                    {/if}
                                                    {foreach name="questionList" item="v" key="k" }
                                                    <tr role="row">
                                                        <td style="display:none"><input type="checkbox" name="ids[]" value="{$v.id}"></td>
                                                        <td>{$v.questionid}</td>
                                                        <td>{$v.subject_name}</td>
                                                        <td>{$v.week_name}</td>
                                                        <td>{$v.qtype_name}</td>
                                                        <td>{$v.question|movehtml|subtext="50"}</td>
                                                        <td>{$v.user_name} / {$v.add_time|date='Y-m-d'}</td>
                                                        <td>
                                                            <a class="btn btn-primary" href="javascript:;" title="查看" onclick="openYemian('/index.php/Admin/Question/questionEdit/id/{$v.questionid}','编辑试题')"><i class="fa fa-pencil"></i></a>
                                                            <a class="btn btn-danger" href="javascript:void(0)" title="删除" onclick="delarticle(this,'确定删除该留言？此操作不可恢复！',{$v.questionid},'/index.php/Admin/Question/questionDel')"><i class="fa fa-trash-o"></i></a>
                                                        </td>
                                                    </tr>
                                                    {/foreach}
                                                    </tbody>
                                                </table>
                                            </form>
                                            <div>
                                                <div style="float:left;display:none"><a href="javascript:void(0);" onclick="reback_select()" id="button-delete6" data-toggle="tooltip" title="删除" class="btn btn-danger" data-original-title="放入回收站">把选中文章放入回收站</a></div>
                                                <div style="float:right;margin-top:-20px;" id="pagelist">{$questionPage|raw}<span style="float:right;margin:25px">共{$questionCount}条</span></div>
                                            </div>
                                            <script>
                                                // 点击分页触发的事件
                                                // $(".pagination a").click(function(){
                                                //     url = $(this).attr('href');
                                                //     ajax_get_table('formSearch',url);
                                                //     return false;
                                                // });
                                            </script>
                                            <script>
                                                // 点击分页触发的事件
                                                // $(".pagination li").removeClass('disabled');
                                                // $(".pagination  a").click(function(){
                                                //     cur_page = $(this).data('p');
                                                //     $(this).attr('href');
                                                //     if ($(this).attr('href') != '#'){
                                                //         window.location.href = $(this).attr('href');
                                                //     }
                                                //     return false;
                                                // });
                                                
                                            </script>                                                
                                            </div>
                                        </div>
                                    </div>
                                </div> <!-- /.box-body -->
                           </div><!-- /.box -->
                        </div>
                   </div>
                </div>
            </div>
        </div>
    </div> 
</div> 


<input id="handle_status" value="" hidden="hidden">
<script>

function delarticle(obj,name,id,url) {
    top.layer.confirm(name,{
        icon : 3,
        btn:['确定','取消'],
    } , function(){
        $.ajax({
            url : url,
            type : "post",
            data : {id:id,act:'del'},
            dataType : "json",
            success:function(data){
                if (data.status == 0) { 
                    top.layer.msg(data.message);
                } else {
                    top.layer.msg(data.message);
                    $(obj).parent().parent().remove();
                    var total = $("#total").html()-1;
                    $("#total").html(total);
                }
            }
        });
    } , function(){
        layer.close(); //再执行关闭 
    })
} 

// 删除选中
function delselect(){
    parent.layer.confirm('确定要删除选中吗？', function(){
        url = window.location.href;
        $.ajax({
            url:"/index.php/Admin/message/delselect",
            data : $('#form-order').serialize(),
            success: function(v){
                var v =  eval('('+v+')');
                parent.layer.msg(v.message, {icon: v.icon,time: 1000});
                if(v.status == 1){
                    window.location = window.location;
                }
                // if(v.hasOwnProperty('status') && (v.status == 1))
                //     getAjaxList('ajaxList',1,"/index.php/Admin/Article/ajaxArticleList");
            }
        });
    });
}
// ajax_get_table('formSearch',"/index.php/Admin/Question/ajaxQuestionList.html?p=1");

// ajax 抓取页面 form 为表单id  page 为当前第几页
// function ajax_get_table(form,url){
//     // cur_page = page; //当前页面 保存为全局变量
//     // var info = $('#page_info').val();
//     $.ajax({
//         type : "POST",
//         url:url,
//         data : $('#'+form).serialize(),// 你的formid
//         success: function(data){
//             $("#ajaxList").html('');
//             $("#ajaxList").append(data);
//         }
//     });
//     return false;
// }
</script>

</body>

</html>